/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2025-01-20
 * Time: 18:26
 */
public class Main {

    public static void merge(int[] nums1, int m, int[] nums2, int n){
        int end1 = m - 1;
        int end2 = n - 1;
        int end = nums1.length - 1;

        while(end1>=0 && end2>=0){
            if (nums1[end1]>nums2[end2]){
                nums1[end--] = nums1[end1--];
            }
            else{
                nums1[end--] = nums2[end2--];
            }
        }

        while (end2>=0){
            nums1[end--] = nums2[end2--];

        }
    }

    public static void main(String[] args) {
        int[] nums1 = {1,2,3,0,0,0};
        int m = 3;
        int[] nums2 = {2,5,6};
        int n = 3;

        merge(nums1,m,nums2,n);
        System.out.println(nums1);

    }
}
